import * as dd from 'dingtalk-jsapi'; // 此方式为整体加载，也可按需进行加载

const ddGetAuthCode = (corpId) => {
  return new Promise((resolve, reject) => {
    dd.getAuthCode({
      corpId: corpId,
      success: (res) => {
        const { code } = res || {};
        if (code) {
          resolve(code)
        } else {
          reject(res)
        }
      },
      fail: (res) => {
        console.log('dd.getAuthCode error', res)
        reject(res)
      }
    });
  })
}
const ddGetLocation = () => {
  return new Promise((resolve, reject) => {
    dd.getLocation({
      success(res) {
        console.log('dd.getLocation success', res)
        if (res) {
          resolve(res)
        } else {
          reject(res)
        }
      },
      fail(err) {
        console.log('dd.getLocation error', err)
        reject(err)
      }
    });
  })
}
export default { ddGetAuthCode, ddGetLocation }